Add regression test for running `cargo test` twice
authorBrian Koropoff <bkoropoff@gmail.com>
Mon, 21 Jul 2014 00:02:09 +0000 (17:02 -0700)
committerBrian Koropoff <bkoropoff@gmail.com>
Mon, 21 Jul 2014 00:33:08 +0000 (17:33 -0700)
tests/support/mod.rs
tests/test_cargo_test.rs

index 227ccf2e79b18632aa90fba6a19451fd425a4d42..ca94f5088e5e3bdcceb1eeacd9d06d1cc3898ed5 100644 (file)
@@ -413,6 +413,20 @@ pub fn basic_bin_manifest(name: &str) -> String {
     "#, name, name)
 }
 
+pub fn basic_lib_manifest(name: &str) -> String {
+    format!(r#"
+        [package]
+
+        name = "{}"
+        version = "0.5.0"
+        authors = ["wycats@example.com"]
+
+        [[lib]]
+
+        name = "{}"
+    "#, name, name)
+}
+
 pub static RUNNING:   &'static str = "     Running";
 pub static COMPILING: &'static str = "   Compiling";
 pub static FRESH:     &'static str = "       Fresh";
index 17c551345637e6fc37f034c2356d126d28ff4a4d..edb30052a7d0fcb19f0add0e5311a0c0503c0ad8 100644 (file)
@@ -1,7 +1,7 @@
 use std::str;
 
-use support::{project, execs, basic_bin_manifest, COMPILING, cargo_dir};
-use support::{ResultTest};
+use support::{project, execs, basic_bin_manifest, basic_lib_manifest};
+use support::{COMPILING, cargo_dir, ResultTest};
 use hamcrest::{assert_that, existing_file};
 use cargo::util::process;
 
@@ -284,3 +284,23 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured\n\n\
                        compiling = COMPILING,
                        dir = p.root().display()).as_slice()));
 })
+
+// Regression test for running cargo-test twice with
+// tests in an rlib
+test!(cargo_test_twice {
+    let p = project("test_twice")
+        .file("Cargo.toml", basic_lib_manifest("test_twice").as_slice())
+        .file("src/test_twice.rs", r#"
+            #![crate_type = "rlib"]
+
+            #[test]
+            fn dummy_test() { }
+            "#);
+
+    p.cargo_process("cargo-build");
+
+    for _ in range(0u, 2) {
+        assert_that(p.process(cargo_dir().join("cargo-test")),
+                    execs().with_status(0));
+    }
+})